/**
 * 
 */
package com.waimai.app.qa.page;

import java.util.HashMap;
import java.util.List;

import org.openqa.selenium.WebElement;

import com.waimai.app.qa.data.Item;
import com.waimai.app.qa.data.PageObject;
import com.waimai.app.qa.util.Logger;

/**
 * @author
 * 
 */
public class IndexPage implements PageObject {
    /**
    *@type id
    *@testData 
    *@locatorValue shopcar_icon
    */
	public Item home_shopcar_icon;
	
	   /**
	    *@type id
	    *@testData 
	    *@locatorValue pair_icon
	    */
		public Item canyin_pair_icon;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue canyin_text
		 */
		public Item canyin_text;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue dialog_layout
		 */
		public Item dialog_layout;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue dialog_close
		 */
		public Item dialog_close;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue home_search_view
		 */
		public Item home_search_view;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue local_search
		 */
		public Item local_search;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue shoplist_adapter_item_shop_name
		 */
		public Item shoplist_adapter_item_shop_name;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue search_sug_shop_name
		 */
		public Item search_sug_shop_name;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue search_box_container
		 */
		public Item search_box_container;
		/**
		 *@type id
		 *@testData 
		 *@locatorValue local
		 */
		public Item local;


 public void init(HashMap<String, Object> items) {
		this.home_shopcar_icon = (Item) items.get("home_shopcar_icon");
		this.canyin_pair_icon = (Item) items.get("canyin_pair_icon");
		this.canyin_text = (Item) items.get("canyin_text");
		this.dialog_layout = (Item) items.get("dialog_layout");
		this.dialog_close = (Item) items.get("dialog_close");
		this.home_search_view = (Item) items.get("home_search_view");
		this.local_search = (Item) items.get("local_search");
		this.shoplist_adapter_item_shop_name = (Item) items.get("shoplist_adapter_item_shop_name");
		this.search_sug_shop_name = (Item) items.get("search_sug_shop_name");
		this.search_box_container = (Item) items.get("search_box_container");
		this.local = (Item) items.get("local");
	}
 
 
	/**
	 * 
		 * @Description：获取搜索结果的店铺名称，返回该的元素
		 * @author：wangwenhui
		 * @time：2017年7月14日下午3:11:02
	 */
	public WebElement getSearchResultTitle(String shopName) {
		List<WebElement> shopList = this.search_sug_shop_name.getWebElementList();
		if(shopList.size() > 0) {
			for(int i=0;i<shopList.size();i++) {
				if(shopList.get(i).getText().equals(shopName)){
					return shopList.get(i);
				}
			}
		}
		return null;
	}
	
	/**
	 * 
		 * @Description：获取搜索结果的店铺名称，返回该的元素
		 * @author：wangwenhui
		 * @time：2017年7月14日下午3:11:02
	 */
	
	public List<WebElement> getSearchResult() { 
		List<WebElement> resultList = this.search_sug_shop_name.getWebElementList();
		if(resultList.size() > 0) {
			Logger.log("有搜索结果");
		}
		return resultList;
	}
}
